<?php
/**
 * Created by PhpStorm.
 * User: pc
 * Date: 2018/8/10
 * Time: 11:30
 */
namespace app\index\model;

use think\Model;
use think\Request;

class Common extends Model{
    public function __construct($data = [])
    {
        parent::__construct($data);

    }

    public function getDataByCondition($condition){
        $condition['is_delete'] = 0;
        return $this->where($condition)->find();
    }
    public function getListByCondition($condition,$order=''){

        $condition['is_delete'] = 0;
        return $this->where($condition)->order($order)->select();
    }
    public function getDataById($id){
        return $this->where(array('id'=>$id,'is_delete'=>0))->find();
    }

    public function updateByCondition($condition,$data){
        return $this->where($condition)->update($data);
    }
    public function getCountByCondition($condition){
        $condition['is_delete'] = 0;
        return $this->where($condition)->count();
    }

    public function getListByConditionPage($condition,$order='',$page='10'){
        $condition['is_delete'] = 0;
        return $this->where($condition)->order($order)->paginate($page,false,['query'=>Request::instance()->param()]);
    }

}